package com.bigdata.controller;

import com.bigdata.pojo.JobBean;
import com.bigdata.service.ServiceFirst;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

@RestController
@RequestMapping("/home")
public class ControllerFirst {

    @Autowired
    private ServiceFirst serviceFirst;

    @RequestMapping("/hotPage")
    public ArrayList hot(){
        ArrayList<JobBean> jobBeans = new ArrayList<>();
        for (int i=1;i<=3;i++){
            JobBean jobBean  =serviceFirst.findHotPosition(i);
            jobBeans.add(jobBean);
        }

        return jobBeans;
    }

    @RequestMapping("/single")
    public void getSingle(@RequestParam("key")  int key){
       Thread t1= new Thread(new Runnable() {
            @Override
            public void run() {
                JobBean jobBean  =serviceFirst.findHotPosition(key);

            }
        });
        Thread t2= new Thread(new Runnable() {
            @Override
            public void run() {
                JobBean jobBean  =serviceFirst.findHotPosition(key);

            }
        });

        Thread t3= new Thread(new Runnable() {
            @Override
            public void run() {
                JobBean jobBean  =serviceFirst.findHotPosition(key);

            }
        });

        t1.start();
        t2.start();
        t3.start();




    }


}
